using System;
using System.Collections.Generic;
using System.Text;
using ProjectBase.Utils;

namespace Clanta.Core.Domain
{
    /// <summary>
    /// 
    /// </summary>
    public abstract class DomainObject<IdT>
    {
        #region Properties

        /// <summary>
        /// ID may be of type string, int, custom type, etc.
        /// Setter is protected to allow unit tests to set this property via reflection and to allow 
        /// domain objects more flexibility in setting this for those objects with assigned IDs.
        /// </summary>
        [System.ComponentModel.DataObjectField(true)]
        public virtual IdT Id
        {
            get { return id; }
            protected set { id = value; }
        }

        #endregion

        #region Methods

        /// <summary>
        /// Transient objects are not associated with an item already in storage.  For instance,
        /// a <see cref="Customer" /> is transient if its Id is 0.
        /// </summary>
        public virtual bool IsTransient()
        {
            return Id == null || Id.Equals(default(IdT));
        }

        #endregion

        #region Members

        private IdT id = default(IdT);

        #endregion
    }
}
